﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AttributeViewModel.cs" >
//   J. Prinz
// </copyright>
// <summary>
//   View Model representing a CAEX-AttributeType <see cref="AttributeType" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace AutomationMLMapper.ViewModels.CAEXObjectViewModels
{
    using CAEX_ClassModel;

    /// <summary>
    ///   View Model representing a CAEX-AttributeType <see cref="AttributeType" />
    /// </summary>
    public class AttributeViewModel : CAEXObjectViewModel<AttributeType>
    {
        #region Constructors and Destructors

        /// <summary>
        ///  Initializes a new instance of the <see cref="AttributeViewModel"/> class. 
        /// </summary>
        /// <param name="attribute">
        ///  CAEX - Attribute-Element 
        /// </param>
        public AttributeViewModel(AttributeType attribute)
            : base(attribute)
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///   DisplayName of the CAEX-Element in the UI used in Headers and Labels
        /// </summary>
        public static new string DisplayName
        {
            get
            {
                return "Attribute";
            }
        }

        /// <summary>
        ///   Unit of an CAEX-Attribute
        /// </summary>
        public string Unit
        {
            get
            {
                return (this.CaexObject != null && this.CaexObject.Unit.Exists()) ? this.CaexObject.Unit.Value : "";
            }

            set
            {
                if (this.CaexObject != null)
                {
                    this.CaexObject.Unit.Value = value;
                    this.OnNotifyPropertyChanged("Unit");
                }
            }
        }

        #endregion
    }
}